package
{
	import com.zheng.pvz.model.proxy.GameProxy;
	import com.zheng.pvz.model.proxy.PlantProxy;
	import com.zheng.pvz.model.proxy.TileProxy;
	import com.zheng.pvz.model.proxy.ZombiesProxy;
	import com.zheng.pvz.model.vo.PlantVo;
	import com.zheng.pvz.model.vo.TileVo;
	import com.zheng.pvz.model.vo.ZombiesVo;
	import com.zheng.pvz.view.GameSprite;
	
	import flash.display.Sprite;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	[SWF(width="800",height="600", backgroundColor="#ffffff",frameRate="18")]
	public class PlantsVsZombies extends Sprite
	{
		public function PlantsVsZombies():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			//设置数据
			var gameProxy:GameProxy=new GameProxy();
			var gameSprite:GameSprite=new GameSprite(gameProxy);
			for(var i:int=0;i<9;i++){
				for(var j:int=0;j<5;j++){
					var tileVo:TileVo=new TileVo();
					tileVo.row=i;
					tileVo.cols=j;
					
					var tileProxy:TileProxy=new TileProxy(tileVo);
					gameProxy.addProxy(tileProxy);
				}
			}
			this.addChild(gameSprite);
			
			var plantVo:PlantVo=new PlantVo();
			plantVo.row=1;
			plantVo.cols=2;
			gameProxy.addProxy(new PlantProxy(plantVo));//添加作物数据
			
			var zombiesVo:ZombiesVo=new ZombiesVo();
			zombiesVo.row=6;
			zombiesVo.cols=2;
			gameProxy.addProxy(new ZombiesProxy(zombiesVo));
		}
	}
}